package com.star.uc.api;

import cn.dev33.satoken.stp.StpUtil;
import com.star.common.core.contract.R;
import com.star.uc.biz.UserBizService;
import com.star.uc.biz.UserQueryBizService;
import com.star.uc.contract.command.LogoffCommand;
import com.star.uc.contract.command.LogoutCommand;
import com.star.uc.contract.query.UserInfoQuery;
import com.star.uc.infras.repository.model.UserInfoBO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * sa-token（面向toc端）
 *
 * @author zhouhengzhe
 * @version 1.0
 * @date 2023/10/18 11:37
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@Tag(name = "UserController", description = "用户相关")
public class UserController {

    private final UserBizService userBizService;

    private final UserQueryBizService userQueryBizService;

    /**
     * 登出
     */
    @PostMapping("/logout")
    @Operation(summary = "退出登录")
    public R<Void> logout(@RequestBody @Valid LogoutCommand logoutCommand) {
        StpUtil.logout(logoutCommand.getUid(),logoutCommand.getClientType());
        return R.ok();
    }

    /**
     * 注销
     */
    @PostMapping("/logoff")
    @Operation(summary = "注销")
    public R<Void> logoff(@RequestBody @Valid LogoffCommand logoffCommand) {
        userBizService.logoff(logoffCommand);
        return R.ok();
    }

    /**
     * 获取用户个人信息
     */
    @PostMapping("/info")
    @Operation(summary = "获取用户个人信息")
    public R<UserInfoBO> info(@RequestBody @Valid UserInfoQuery userInfoQuery) {
        return R.ok(userQueryBizService.info(userInfoQuery));
    }

    /**
     * 身份证认证
     */


    /**
     * 绑定第三方接口
     */
    @PostMapping("/bind")
    @Operation(summary = "绑定第三方接口")
    public R<Void> bind() {
        return R.ok();
    }


    /**
     * 修改密码（只针对于手机号/邮箱）
     */
    @PostMapping("/changePassword")
    @Operation(summary = "修改密码（只针对于手机号/邮箱）")
    public R<Void> changePassword() {
        return R.ok();
    }


    /**
     * 查看当前用户绑定的三方账户信息
     */
    @PostMapping("/listBind")
    @Operation(summary = "查看当前用户绑定的三方账户信息")
    public R<Void> listBind() {
        return R.ok();
    }


}
